#include <stdio.h>
#include <algorithm>
#include <math.h>
using namespace std;

#define rep(i,n) for (int i=0; i<n; i++)

#define TRACE(x...) 
#define PRINT(x...) TRACE(printf(x))

#define INF 0x3f3f3f3f

typedef struct {
	double x, m, v;
} Ball;

int n;
double colTime[12][12];
Ball bs[12];
int t;
double m;
int ca,cb;
double prev;
double colS;
double v1,v2;
double timeElapsed;
double lastCol;
bool cols[12];

int main() {
	scanf("%d %d", &n, &t);
	rep(i,n) scanf("%lf %lf %lf", &bs[i].x, &bs[i].v, &bs[i].m);
	timeElapsed=0;
	lastCol=0;

	PRINT("T is %d\n\n", t); 

	while (1) {
		rep(i,n) rep(j,n) {
			if (i==j) {
				colTime[i][j]=INF;
				continue;
			}
			if (bs[i].v==bs[j].v) {
				colTime[i][j]=INF;
				continue;
			}

			colTime[i][j]=(double)(bs[i].x-bs[j].x)/(double)(bs[j].v-bs[i].v);
			if (colTime[i][j]<=0) colTime[i][j]=INF;
		}

		TRACE(
			rep(i,n) { 
				rep(j,n) printf("%lf ", colTime[i][j]);
				printf("\n");
			}

			printf("\n");
		)
				
		m=INF;

		rep(i,n) rep(j,n) {
			if (m>colTime[i][j]) {
				m=colTime[i][j];
			}
		}
	
		timeElapsed+=m;

		if (timeElapsed>t) break;
		lastCol=timeElapsed;
	
		rep(i,n) cols[i]=false;
	
		rep(i,n) for (int j=i+1; j<n; j++) {
			if (colTime[i][j]>m) continue;			

			ca=i; cb=j;
			PRINT("%d collides with %d at time %lf\n", ca, cb, timeElapsed);

			colS = bs[ca].x+(bs[ca].v)*m;
			bs[ca].x=colS;
			bs[cb].x=colS;
			v1=bs[ca].v; v2=bs[cb].v;		

			bs[ca].v = (bs[ca].m-bs[cb].m)*v1+2*(bs[cb].m)*v2;
			bs[ca].v/=bs[ca].m+bs[cb].m;	

			bs[cb].v = (bs[cb].m-bs[ca].m)*v2+2*(bs[ca].m)*v1;
			bs[cb].v/=bs[ca].m+bs[cb].m;	
			
			cols[ca]=true; cols[cb]=true;
		}

		rep(i,n) {
			if (cols[i]) continue;

			bs[i].x+=m*bs[i].v;
		}

		TRACE(
				printf("\n");
				rep(i,n) printf("Ball %d: %lf\n", i, bs[i].x);
				printf("\n");
		     )
	}

	rep(i,n) {
		bs[i].x+=(t-lastCol)*bs[i].v;	
	}

	rep(i,n) printf("%.9lf\n", bs[i].x);

	return 0;
}
